package org.nepu.scr.indexrate.converter.drillingrate.keydevice.nozzlesystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.nozzlesystem.Throttle;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class ThrottleConverter implements AttributeConverter<Throttle, String> {
    @Override
    public String convertToDatabaseColumn(Throttle throttle) {
        return JSONUtil.toJsonStr(throttle);
    }

    @Override
    public Throttle convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, Throttle.class);
    }
}
